﻿using Com.PhilChuang.Mobile.Apps.LocationSender.Model.Data;
using Com.PhilChuang.Pmvp.Ui.Views.Impl.ViewModels;

namespace Com.PhilChuang.Mobile.Apps.LocationSender.Ui.Views.Impl.ViewModels
{
	public class WelcomePageViewModel : AbstractLocationSenderAppViewModel
	{
		public bool SelectContactsButtonEnabled
		{ get { return CurrentPosition != null; } }

		private bool myCanResend;
		public bool CanResend
		{
			get { return myCanResend; }
			set
			{
				myCanResend = value;
				RaisePropertyChanged (() => CanResend);
				RaisePropertyChanged (() => UseLastRecipientsAndFormatButtonEnabled);
			}
		}

		public bool UseLastRecipientsAndFormatButtonEnabled
		{ get { return CanResend && CurrentPosition != null; } }


		private GeoCoordinate m_LastPosition = null;
		protected override void OnPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e)
		{
			if (e.PropertyName == INPCHelper.GetPropertyName (() => CurrentPosition))
			{
				if (m_LastPosition == null)
				{
					RaisePropertyChanged (() => SelectContactsButtonEnabled);
					RaisePropertyChanged (() => UseLastRecipientsAndFormatButtonEnabled);
				}
				m_LastPosition = CurrentPosition;
			}
		}
	}
}
